﻿using Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using uPLibrary.Networking.M2Mqtt.Messages;

namespace MQTTTool.Page.Mqtt
{
	public partial class MqttConfigPage : Form
	{
		IDictionary<int, MqttMsgBase> keyCodeCharMap;   //生命一个Dictionary来存储整型值和枚举值的对应关系

		public MQConfig config;
		public MqttConfigPage(MQConfig config)
		{
			InitializeComponent();
			
			this.config = config;
			 this.textBoxX_Ip.Text =config.MQTTIP;
			this.integerInput_Port.Value= config.MQTTPort ;
			//keyCodeCharMap[this.integerInput_QOS.Value] = config.MsgBase;
			textBoxX_password.Text = config.password;
			textBoxX_sbbh.Text= config.sbbh ;
			textBoxX_username.Text = config.username;
		}
		/// <summary>
		/// 方便int转换枚举
		/// </summary>
	
		private MQConfig GetCanShu() {
			return config;
		}


		private void buttonX2_Click(object sender, EventArgs e)
		{
			config.MQTTIP = this.textBoxX_Ip.Text;
			config.MQTTPort = this.integerInput_Port.Value;
		
			config.password = textBoxX_password.Text;
			config.sbbh = textBoxX_sbbh.Text;
			config.username = textBoxX_username.Text;
			this.DialogResult = DialogResult.OK;
		}

		private void buttonX1_Click(object sender, EventArgs e)
		{
			this.Close();
		}
	}
}
